<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>添加用户</title>
		<script type="text/javascript" src="/js/jquery-1.11.1.js"></script>
		<script type="text/javascript" src="/js/bootstrap.js"></script>
		<link rel="stylesheet" type="text/css" href="/css/bootstrap.css"/>
		<link rel="stylesheet" type="text/css" href="/css/style.css"/>
		<style>
			label span{color: #ff0000; padding-right: 5px;}
		</style>
	</head>

	<body>
		<h2>添加用户</h2>
		<form id="myForm" class="form-horizontal" method="post" action="/user">
			<div class="form-group">
				<label class="col-sm-1 control-label"><span>*</span>用户编号</label>
				<div class="col-sm-9">
					<input required="required" name="u_id" class="form-control" placeholder="请输入 用户id"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-1 control-label"><span>*</span>登录账号</label>
				<div class="col-sm-9">
					<input required="" name="u_logInName" class="form-control" placeholder="请输入 登录的账号"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-1 control-label"><span>*</span>登录密码</label>
				<div class="col-sm-9">
					<input required="" name="u_passWord" class="form-control" type="password"/>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-1 control-label">姓名</label>
				<div class="col-sm-9">
					<input name="u_name" class="form-control" placeholder="请输 用户真实姓名"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-1 control-label">邮箱</label>
				<div class="col-sm-9">
					<input name="u_email" class="form-control" placeholder="请输入 用户邮箱"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-1 control-label">联系方式</label>
				<div class="col-sm-9">
					<input name="u_phone" class="form-control" placeholder="请输入 联系方式"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-1 control-label">用户状态</label>
				<div class="col-sm-2">
					<select name="u_state" class="form-control">
         				<option value="-1">是否禁用</option>
         				<option value="0">正常</option>
         				<option value="1">禁用</option>
			      	</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-1 control-label"></label>
				<div class="col-sm-9">
					<button id="btnAdd" type="button" class="btn btn-sm btn-info">提&nbsp;交</button>
					<button type="reset"  class="btn btn-sm btn-warning">重&nbsp;置</button>
				</div>
			</div>
		</form>		
	</body>
</html>
<script>
	$(function () {
		//提交按钮的单击事件
		$("#btnAdd").click(function () {
			$.ajax({
				type: "POST",
				url: "/user/",
				data: $("#myForm").serialize(),
				dataType:"json",
				success: function(vo){
					if(vo.code==200) {
						alert("操作成功！");
						window.location.href = "/pages/user/list.html";
					}else{
						alert("添加失败！"+vo.msg);
					}
				}
			});
		});
	});
</script>